<?php

namespace Home\Controller;
use Think\Controller;

class ExcelController extends CommonController {
	public function import(){
		$this->display();
	}





	public function do_import(){
		$dir = dirname(_FILE_);//获得编译文件当前目录
		$dir = str_replace("\\", "/", $dir)."/";
		$filename = 'test.xlsx';
		$path = $dir.$filename;
		$path = "./uploads/".$filename;
		$result = move_uploaded_file($_FILES['uploadfile']['tmp_name'], $path);
		if($result){

			import("Org.Util.PHPExcel.PHPExcel");//初始化入口类
			// $PHPExcel=new \PHPExcel();

			import("Org.Util.PHPExcel.Reader.Excel5");//如果excel文件后缀名为.xls，导入这个类
			$PHPReader=new \PHPExcel_Reader_Excel5();

			import("Org.Util.PHPExcel.Reader.Excel2007");//如果excel文件后缀名为.xlsx，导入这下类
			$PHPReader=new \PHPExcel_Reader_Excel2007();
			
			$objPHPExcel = $PHPReader->load($path);
			$currentSheet = $objPHPExcel->getSheet(0);
			$allRow =  $currentSheet->getHighestRow();

			
			for($i=2;$i<=$allRow;$i++){
				$item = 'A'.$i;
				$itemval = $currentSheet->getCell($item)->getValue();
				echo $itemval."<br>";
			}

		}
	}








}
?>